﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
 

namespace nadModel.ApproverTimeAndExpense
{
    public partial class TimeAndExpenseCoPartEntityProcess : AbstractEntityProcess
    {
        public override AbstractEntity[] PackEntity(object obj)
        {
            //pack entries
            List<TimeAndExpenseCoPartEntity> entryList = new List<TimeAndExpenseCoPartEntity>();
            TimeAndExpenseCoPartEntity entry;
            try
            {
                DataTable dt = (DataTable)obj;
                if (dt == null)
                {
                    return null;
                }

                foreach (DataRow item in dt.Rows)
                {
                    entry = new TimeAndExpenseCoPartEntity();
                    entry.Company = item[TimeAndExpenseCoPartEntity.COMPANY].ToString();
                    entry.Employeenum = item[TimeAndExpenseCoPartEntity.EMPLOYEENUM].ToString();
                    entry.LaborHedSeq = int.Parse(item[TimeAndExpenseCoPartEntity.LABORHEDSEQ].ToString());
                    entry.LaborTypePseudo = item[TimeAndExpenseCoPartEntity.LABORTYPEPSEUDO].ToString();
                    entry.JobNum = item[TimeAndExpenseCoPartEntity.JOBNUM].ToString();
                    entry.AssemblySeq = int.Parse(item[TimeAndExpenseCoPartEntity.ASSEMBLYSEQ].ToString());
                    entry.OprSeq = int.Parse(item[TimeAndExpenseCoPartEntity.OPRSEQ].ToString());
                    entry.PartQty = decimal.Parse(item[TimeAndExpenseCoPartEntity.PARTQTY].ToString());
                    entry.Number01 = decimal.Parse(item[TimeAndExpenseCoPartEntity.NUMBER01].ToString());
                    entry.Status = item[TimeAndExpenseCoPartEntity.STATUS].ToString();
                    entry.SysRowId = item[TimeAndExpenseCoPartEntity.SYSROWID].ToString();
                    entry.DtlSysRowId = item[TimeAndExpenseCoPartEntity.DTLSYSROWID].ToString();
                    entry.PartNum = item[TimeAndExpenseCoPartEntity.PARTNUM].ToString();
                    entryList.Add(entry);
                }
            }
            catch (Exception ex)
            {
                Log("ERROR: error packing entity", LogLevel.FATAL);
                Log(ex.ToString(), LogLevel.FATAL);
                throw ex;
            }
            return (AbstractEntity[])entryList.ToArray();

        }
    }
}
